#include "gm_sc_digest_mgr.h"
#include <string.h>
gm_sc_digest_mgr::gm_sc_digest_mgr(void)
{
}

gm_sc_digest_mgr::~gm_sc_digest_mgr(void)
{
}


void gm_sc_digest_mgr::clear()
{
	mk_node* pHead = _sc_digest_list.get_head();
	while (pHead != NULL)
	{
		mk_node *node = pHead;
		delete node->get_data();
		pHead = node->get_next_node();
	}
	_sc_digest_list.remove_all();
	return ;
}

int gm_sc_digest_mgr::add_digest(gm_sc_digest *sc_key)
{
	return _sc_digest_list.add(sc_key);
}

ULONG gm_sc_digest_mgr::remove_digest(gm_sc_digest *sc_key)
{
	mk_node* pHead = _sc_digest_list.get_head();
	if(pHead == NULL) return 0;
	gm_sc_digest * pkey = (gm_sc_digest *)pHead->get_data();

	if(pkey == sc_key)
	{
		delete pkey;
		_sc_digest_list.remove(pkey);
		return SAR_OK;
	}

	mk_node* pNode = pHead->get_next_node();

	while(pNode != NULL)
	{
		pkey = (gm_sc_digest *)pNode->get_data();
		if(pkey == sc_key)
		{
			delete pkey;
			_sc_digest_list.remove(pkey);
			return SAR_OK;
		}
		pNode = pNode->get_next_node();
	}

	return SAR_FAIL;
}